package nz.co.senanque.bundle1;

import nz.co.senanque.perspectivemanager.App;
import nz.co.senanque.perspectivemanager.AppFactory;
import nz.co.senanque.perspectivemanager.Blackboard;

import com.vaadin.ui.MenuBar;
import com.vaadin.ui.MenuBar.Command;
import com.vaadin.ui.MenuBar.MenuItem;

/**
 * @author Roger Parkinson
 *
 */
public class AppFactoryImpl implements AppFactory {
	
	/* (non-Javadoc)
	 * @see nz.co.senanque.bundle1.AppFactory#createApp()
	 */
	@Override
	public App createApp(Blackboard blackboard)
	{
		App ret = new App();
		final Layout layout = new Layout();
		layout.setBlackboard(blackboard);
		ret.setComponentContainer(layout);
		MenuBar menuBar = new MenuBar();
		final MenuBar.MenuItem file = menuBar.addItem("File", null);
		file.addItem("close", new Command(){

			private static final long serialVersionUID = 7142024506317299918L;

			public void menuSelected(MenuItem selectedItem) {
				layout.close();
				
			}});
		ret.setMenuBar(menuBar);
		return ret;
	}

}
